$(window).scroll(function(){
               if ((verOffset=navigator.userAgent.indexOf("Chrome"))!=-1)
                   {
                       var bottom_up = 700 - $(this).scrollTop();
                        if($(this).scrollTop() != 0 && $(this).scrollTop() < document.getElementById("header").offsetHeight){
                                document.getElementById("tc_right").style.top =  bottom_up + "px";
                        }
                        if($(this).scrollTop() >= document.getElementById("header").offsetHeight){
                                document.getElementById("tc_right").style.top = 0 + "px";
                        }
                   }
               else
                   {
                        var bottom_up = 700 - $(this).scrollTop();
                        if($(this).scrollTop() != 0 && $(this).scrollTop() < document.getElementById("header").offsetHeight){
                                document.getElementById("tc_right").style.top =  bottom_up + "px";
                        }
                        if($(this).scrollTop() >= document.getElementById("header").offsetHeight){
                                document.getElementById("tc_right").style.top = 0 + "px";
                    }
                }
});    
(function($){
$(document).ready(function(){

$('.navigation a').click(function(e){
	e.preventDefault();

	$('.on').removeClass('on');

	el = $(this);

	name = el.attr('href');

	pos = $(name).position().top;

	el.addClass('on');

	$('html,body').stop().animate({scrollTop:pos},2600,'easeInQuart');
	return false;
});

	$(window).scroll(function(){
		t = $(window).scrollTop();

		$('.main').find('.page').each(function(){
			el = $(this);
			p = el.position().top;

			if(p <= t){
				id = el.attr('id');
				$('.on').removeClass('on');
				$("[href='#"+id+"']").addClass('on');
			}
		});
	});

});

})(jQuery);
(function($){
$(document).ready(function(){

$('.nav a').click(function(e){
	e.preventDefault();

	$('.on').removeClass('on');

	el = $(this);

	name = el.attr('href');

	pos = $(name).position().top;

	el.addClass('on');

	$('html,body').stop().animate({scrollTop:pos},1800,'easeInQuart');
	return false;
});

	$(window).scroll(function(){
		t = $(window).scrollTop();

		$('.main').find('.page').each(function(){
			el = $(this);
			p = el.position().top;

			if(p <= t){
				id = el.attr('id');
				$('.on').removeClass('on');
				$("[href='#"+id+"']").addClass('on');
			}
		});
	});

});

})(jQuery);
//	$(document).ready(function() {
//        initialize_tabs("navigation","content");  
//    });

	$(window).scroll(function () { 
		
		var myWidth;
		var myHeight;
		
		if(typeof(window.innerWidth) == 'number'){ 
		//Non-IE 
			 myWidth = window.innerWidth;
			 myHeight = window.innerHeight; 
		} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { 
			 //IE 6+ in 'standards compliant mode' 
			 myWidth = document.documentElement.clientWidth; 
			 myHeight = document.documentElement.clientHeight; 
		} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) { 
			 //IE 4 compatible 
			 myWidth = document.body.clientWidth; 
			 myHeight = document.body.clientHeight; 
		}  
		var viewPortHeight = parseInt(document.documentElement.clientHeight); 
		var scrollHeight = parseInt(document.body.getBoundingClientRect().top);
		if(myWidth>1078){
		
		var ht=myWidth-1078;
		var chinh=(ht/2)+880;
		var nav =(ht/2)-160;
			$("#top").css("left",chinh+"px");
			$("#nav").css("right",nav+"px");
		}
		$("#nav").show();
		
		if(viewPortHeight>100){ 
			$("#top").css("top",200+"px");
			$("#nav").css("top",200+"px");
		}else{
			$("#top").css("top",200+"px");
			$("#nav").css("top",200+"px");
		} 
		
		if(scrollHeight <-400){  
			$("#top").show(); 
		}else{
			$("#top").hide();
		}
		 
		});
		function showTopLink(){
		$('html, body').animate({scrollTop: '0px'}, 900);
		
		}
        
$(function(){
    $("select[name=server]").change(function(){
       //alert($(this).val());
        $("#character-loader").show();
        $("select[name=character]").hide();
        $.ajax({
          type: "POST",
          url: _base_url+"event/quay-so/get_character",
          data: {server: $(this).val()}
        }).done(function(character) {
              if(character==""){
                    $("select[name=character]").html('<option value="">Chưa tạo nhân vật</option>');
              } else {
                $("select[name=character]").html('<option value="'+character+'">'+character+'</option>');
              }
              $("#character-loader").hide();
              $("select[name=character]").show();
        });
    });
    
    $("input[name=clear]").click(function(){
        //clear input
        $("form input[type=text]").each(function(){
            $(this).val("");
        });
        
        //clear select
        $("form select").each(function(){
            $(this).val("");
        });
    });
    
    $("input[name=cmnd]").keydown(function(event) {
    	// Allow only backspace and delete
    	if ( event.keyCode == 46 || event.keyCode == 8 ) {
    		// let it happen, don't do anything
    	}
    	else {
    		// Ensure that it is a number and stop the keypress
    		if (event.keyCode < 48 || event.keyCode > 57 ) {
    			event.preventDefault();	
    		}	
    	}
    });
});